package com.dong.dubbo.consumer.controller;

import com.dong.dubbo.consumer.service.TestRemoteCall;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.common.utils.NetUtils;
import org.apache.dubbo.config.RegistryConfig;
import org.apache.dubbo.config.ServiceConfig;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author dengxiudong
 * @Date 2024/10/14 下午3:11
 */
@Slf4j
@RestController
public class TestController
{
    @Resource
    private TestRemoteCall testRemoteCall;

    // @Resource
    // private final RegistryConfig registryConfig;
    //
    // public TestController(ApplicationContext applicationContext)
    // {
    //     // 获取注册中心配置
    //     this.registryConfig = applicationContext.getBean(RegistryConfig.class);
    // }


    @GetMapping("/test")
    public String test()
    {
        log.info("---------------TestController-");
        log.info("LocalAddress: {}", NetUtils.getLocalAddress());
        log.info("LocalHost: {}", NetUtils.getLocalHost());
        log.info("LocalPort: {}", NetUtils.getRandomPort());

        testRemoteCall.testIdCall();

        return "success";
    }


}
